//
//  ContactUsTableVC.m
//  BCW
//
//  Created by Mac on 16/3/30.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "ContactUsTableVC.h"
#import <SVProgressHUD.h>
#import "UIBarButtonItem+CustomItem.h"
#import "HBWNetDataManager.h"

#define BCWHost @""
@interface ContactUsTableVC ()

@property (weak, nonatomic) IBOutlet UILabel *phoneL;
@property (weak, nonatomic) IBOutlet UILabel *QQL;
@property (weak, nonatomic) IBOutlet UILabel *weiXinL;

@property (nonatomic, strong) NSDictionary  *source;

@end

@implementation ContactUsTableVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"联系我们";
    
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImage:@"return" hightImage:@"return" target:self action:@selector(popViewController:)];
    
    // loadData
    [NetMgr aboutMeSuccess:^(id responeseObj) {
        _source = [responeseObj[@"data"] firstObject];
        
        _phoneL.text = [NSString stringWithFormat:@"电话:%@", _source[@"phone"]];
        _QQL.text = [NSString stringWithFormat:@"QQ:%@", _source[@"qq"]];
        _weiXinL.text = [NSString stringWithFormat:@"微信:%@", _source[@"weChat"]];
    } failuer:^(NSError *error) {
        
    }];
}

//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
//    if (_source) {
//        return 3;
//    }
//    else{
//        return 0;
//    }
//}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    if (indexPath.section == 0) {
        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
        pasteboard.string = [cell.textLabel.text substringFromIndex:3];
        
        [SVProgressHUD showSuccessWithStatus:@"已经拷贝到剪切板"];
    }
    else{
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:_source[@"call_bcaiweb"]]];
    }
}


- (void)popViewController:(id)sender{
    [self.navigationController popViewControllerAnimated:YES];
}

@end
